<?php include '../admin_head.php';
//获取分类信息
$sql = "select id,name,path,concat(path,id) bpath from ".PRE."category order by bpath";
	$result = mysql_query($sql);
	if($result && mysql_num_rows($result)>0){
		while($row = mysql_fetch_assoc($result)){
			$row['name'] = str_repeat('&nbsp;&nbsp;',(strlen($row['path'])-2)/2).$row['name'];
			$catelist[] = $row;
		}
	}
	$list = $_GET['list'];
	$pid = empty($_GET['id'])? 0 : $_GET['id'];
?>
	
		<div class="admin_main_nav">分类管理&gt;&gt;添加分类</div>
		<div id="admin_addcate" class="admin_form admin_main_index">
		<div class="user_index_title"></div>
			<table width="500">
			<form action="action.php?a=add&list=<?php echo $list ?>" method="post">
				<tr>
					<th>所属分类：</th>
					<td>
						<select name="pid">
							<option value="0">顶级分类</option>
							<?php foreach($catelist as $tr):?>
							<option value="<?php echo $tr['id'] ?>" <?php echo $pid == $tr['id'] ? 'selected': '' ; ?>><?php echo $tr['name'] ?></option>
							<?php endforeach;?>
						</select>
					</td>
				</tr>
				<tr>
					<th>分类名称：</th>
					<td><input type="text" name="name" /></td>
				</tr>
				<tr>
					<td colspan="2" class="submit"><input type="submit" value="添加分类" /></td>
				</tr>
			</form>
		</table>
		</div>

		
<?php include '../admin_footer.php';?>
